import 'package:flutter/material.dart';
import 'package:hxdj/common/base_page/base_page.dart';
import 'package:hxdj/common/components/my_borde.dart';
import 'package:hxdj/common/my_header_global.dart';
import 'package:hxdj/login/login_viewmodel.dart';

class RegisterPage extends StatefulWidget {
  static String routeName = "/registerPage";

  const RegisterPage({super.key});

  @override
  State<RegisterPage> createState() => _RegisterPageState();
}

class _RegisterPageState extends State<RegisterPage> {
  @override
  Widget build(BuildContext context) {
    return BasePage<LoginViewModel>(
        onModelReady: (model) {
          // 页面初始化完成后的回调
          // model.cancelAccount();
        },
        viewModel: LoginViewModel(),
        builder: (BuildContext context, LoginViewModel? model, Widget? child) {
          return Scaffold(
            body: Center(
                child: Column(
              children: [
                //注册按钮

                GestureDetector(
                  onTap: () {
                    model?.login("account", "password");
                  },
                  child: Container(
                    margin: const EdgeInsets.only(top: 70),
                    alignment: Alignment.center,
                    child: MyBorder(
                      radius: 25,
                      backgroundColor: MyColours.appMain,
                      child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 18),
                          child: const Text("登录", style: TextStyle(fontSize: 15, color: Colors.black))),
                    ),
                  ),
                ),

                GestureDetector(
                  onTap: () {
                    // model?.logout();
                  },
                  child: Container(
                    margin: const EdgeInsets.only(top: 70),
                    alignment: Alignment.center,
                    child: MyBorder(
                      radius: 25,
                      backgroundColor: MyColours.appMain,
                      child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 18),
                          child: const Text("退出", style: TextStyle(fontSize: 15, color: Colors.black))),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // model?.getRecentConversationList();
                  },
                  child: Container(
                    margin: const EdgeInsets.only(top: 70),
                    alignment: Alignment.center,
                    child: MyBorder(
                      radius: 25,
                      backgroundColor: MyColours.appMain,
                      child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 18),
                          child: const Text("加载最近会话", style: TextStyle(fontSize: 15, color: Colors.black))),
                    ),
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // model?.getUnreadConversations();
                  },
                  child: Container(
                    margin: const EdgeInsets.only(top: 70),
                    alignment: Alignment.center,
                    child: MyBorder(
                      radius: 25,
                      backgroundColor: MyColours.appMain,
                      child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 18),
                          child: const Text("加载未读消息的会话", style: TextStyle(fontSize: 15, color: Colors.black))),
                    ),
                  ),
                ),

                GestureDetector(
                  onTap: () {
                   
                  },
                  child: Container(
                    margin: const EdgeInsets.only(top: 70),
                    alignment: Alignment.center,
                    child: MyBorder(
                      radius: 25,
                      backgroundColor: MyColours.appMain,
                      child: Container(
                          padding: const EdgeInsets.symmetric(horizontal: 100, vertical: 18),
                          child: Text("获取所有未读数 ${model?.totalUnreadCount}",
                              style: const TextStyle(fontSize: 15, color: Colors.black))),
                    ),
                  ),
                ),
              ],
            )),
          );
        });
  }
}
